package com.sj.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 角色表
 * </p>
 *
 * @author 孙峻
 * @since 2022-03-09
 */
@Getter
@Setter
@Accessors(chain = true)
@ApiModel(value = "Role对象", description = "角色表")
public class Role implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("角色id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("角色名")
    private String name;

    @ApiModelProperty("角色值")
    private String code;

    @ApiModelProperty("角色备注")
    private String remark;

    @ApiModelProperty("角色等级")
    private Integer level;

    @ApiModelProperty("是否删除 1 删除 0 未删除")
    @TableLogic
    private Boolean del;

    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime updateTime;


    public static RoleBuilder builder() {
        return new RoleBuilder();
    }

    public static final class RoleBuilder {
        private Integer id;
        private String name;
        private String code;
        private String remark;
        private Integer level;
        private LocalDateTime createTime;
        private LocalDateTime updateTime;

        private RoleBuilder() {
        }

        public RoleBuilder id(Integer id) {
            this.id = id;
            return this;
        }

        public RoleBuilder name(String name) {
            this.name = name;
            return this;
        }

        public RoleBuilder code(String code) {
            this.code = code;
            return this;
        }

        public RoleBuilder remark(String remark) {
            this.remark = remark;
            return this;
        }

        public RoleBuilder level(Integer level) {
            this.level = level;
            return this;
        }

        public RoleBuilder createTime(LocalDateTime createTime) {
            this.createTime = createTime;
            return this;
        }

        public RoleBuilder updateTime(LocalDateTime updateTime) {
            this.updateTime = updateTime;
            return this;
        }

        public Role build() {
            Role role = new Role();
            role.setId(id);
            role.setName(name);
            role.setCode(code);
            role.setRemark(remark);
            role.setLevel(level);
            role.setCreateTime(createTime);
            role.setUpdateTime(updateTime);
            return role;
        }
    }
}
